<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js事件绑定</title>
</head>
<body>
<input type="button" onclick="on(1)" value="事件绑定1" id="btn1">
<input type="button" value="事件绑定2" id="btn2">
<script>

  function on(a){
    alert("事件"+a+"被触发");
  }

  //第二种方法
  var  oBtn  = document.getElementById("bnt2");
  oBtn.onclick = function (){
    alert("事件"+a+"被触发");
  }
  //oBtn.onclick = on(2);


  //第三种方法
  oBtn.addEventListener("click",function (){
    on(2);
  });
</script>
</body>
</html>